package cii_lib;

import cii_lib.*;
//import cii_components.*;

public class cii_lib_test{

  public static void main(String[] args) {
//    System.out.print(CRPC.FLAG_CTRL_MODE.Item().SET_HIGH.Name()+"\n");
//    System.out.print(CRPC.CONS_DESCR_WIDTH.Name()+"\n");
//    CCII_DSP dsp=new CCII_DSP(CII_LIB_TEST_cfg_tab.ITAB,0,0,null);
//    System.out.print(dsp.COMP_ADD(0).COMP_ID(0).IPAR_USER_REG_NUM().Name()+"\n");
//    System.out.print(CCII_IDENTIFICATOR.CONS_TEST_STR.Name(dsp.COMP_ID(0).CII_IDENTIFICATOR())+": "+CCII_IDENTIFICATOR.CONS_TEST_STR.Get()+"\n");
//    System.out.print(dsp.COMP_ADD(0).IPAR_DATA_IN_SIZE().PathName()+": "+dsp.COMP_ADD(0).IPAR_DATA_IN_SIZE().Get()+"\n");
    
//    CIIdata data = new CIIdata(256);
//    data.SetBin(19,8,"10011100");
//    System.out.print("long: "+data.GetBin(19,8)+"\n");
    
    JSserver Srv=new JSserver(4);
    CIIdata Word=new CIIdata(3*32+32/2);
    CIIdata Area=new CIIdata(2*32+32/2);
    CIIdata Bits=new CIIdata(8);
    System.out.println("connecting source");
    try{
      Srv.Open("localhost",8011);
      System.out.println("res: "+Srv.Read(0));
      for (int grp=0; grp<3; grp++)
	for (int num=0; num<8; num++){
	  Word.SetStr(""+num+grp+"alfabeta"+"_"+num+"_"+grp);
	  Srv.CII_WORD_Write(32, Word.GetWidth(), 8, 3, 0, num, grp, Word);
	  Srv.CII_WORD_Read(32, Word.GetWidth(), 8, 3, 0, num, grp, Word);
	  System.out.println("res: "+Word.GetStr());
	}
      for (int num=0; num<20; num++){
	Area.SetStr(""+num+"alfabeta");
	Srv.CII_AREA_Write(32, Area.GetWidth(), 256, 1, 256, num, 0, Area);
	Srv.CII_AREA_Read(32, Area.GetWidth(), 256, 1, 256, num, 0, Area);
	System.out.println("res: "+Area.GetStr());
      }
      for (int grp=0; grp<3; grp++)
	for (int num=0; num<8; num++){
	  Srv.CII_WORD_Read(32, Word.GetWidth(), 8, 3, 0, num, grp, Word);
	  System.out.println("res: "+Word.GetStr());
	}
      System.out.println("res: "+Word.GetHex());
      System.out.println("res: "+Word.GetStr());
      System.out.println("res: "+Word.GetValue(0,32));
      System.out.println("res: "+Word.GetValue(32,32));
      System.out.println("res: "+Word.GetValue(64,32));
      System.out.println("res: "+Word.GetValue(96,16));
      Bits.SetHex("ef");
      Srv.CII_BITS_Write(32, 8, 1, 4, 4, 0, 3, Bits);
      Srv.CII_BITS_Read(32, 8, 1, 4, 4, 0, 3, Bits);
      System.out.println("res: "+Bits.GetHex());
      Srv.Close();
      Srv=null;
    } catch (Exception e){System.out.print("server error occured");}
    try{
      if(Srv!=null)
        Srv.Close();
    } catch (Exception e){System.out.print("server close error");}
  }
}
